const Express = require("express");
const UserSymptomServer = require("../../servers/UserSymptom");
const ResponseHelper = require("../ResponseHelper");
const router = Express.Router();

/**
 * 获取所有症状
 */
router.get("/getAllUserSymptom/:id", async (req, res) => {
  try {
    const id = req.params.id;
    const result = await UserSymptomServer.getAll(id);
    ResponseHelper.sendData(result, res);
  } catch (err) {
    ResponseHelper.sendErr(err, res);
  }
});

/**
 * 批量添加症状
 */
router.post("/bulkCreateUserSymptom", async (req, res) => {
  try {
    const result = await UserSymptomServer.bulkCreate(req.body);
    ResponseHelper.sendData(result, res);
  } catch (err) {
    ResponseHelper.sendErr(err, res);
  }
});


/**
 * 添加一个症状
 */
router.post("/addUserSymptom", async (req, res) => {
  try {
    const result = await UserSymptomServer.add(req.body);
    ResponseHelper.sendData(result, res);
  } catch (err) {
    ResponseHelper.sendErr(err, res);
  }
});

/**
 * 更新症状
 */
router.post("/updateUserSymptom/:id", async (req, res) => {
  try {
    const id = req.params.id;
    const result = await UserSymptomServer.update(id);
    ResponseHelper.sendData(result, res);
  } catch (err) {
    ResponseHelper.sendErr(err, res);
  }
});

/**
 * 根据id获取症状
 */
router.post("/getUserSymptom/:id", async (req, res) => {
  try {
    const id = req.params.id;
    const result = await UserSymptomServer.getById(id);
    ResponseHelper.sendData(result, res);
  } catch (err) {
    ResponseHelper.sendErr(err, res);
  }
});

/**
 * 根据id删除症状
 */
router.post("/delUserSymptom/:id", async (req, res) => {
  try {
    const id = req.params.id;
    const result = await UserSymptomServer.delete(id);
    ResponseHelper.sendData(result, res);
  } catch (err) {
    ResponseHelper.sendErr(err, res);
  }
});

module.exports = router;
